import 'dart:convert';

import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';

import '../../bean/house_list_entity.dart';
import 'state.dart';

class HouseLogic extends GetxController with GetSingleTickerProviderStateMixin {
  final HouseState state = HouseState();

  late TabController tabController;

  late PageController pageController;


  late BrnSelectionEntityListBean? selectionData;

  late List<HouseListData>? houseList= <HouseListData>[];

  @override
  void onInit() {
    super.onInit();
    rootBundle.loadString("assets/config/multi_list_filter.json").then(
        (value) => {
              selectionData =
                  BrnSelectionEntityListBean.fromJson(json.decode(value))
            });
    rootBundle.loadString("assets/config/house_list.json").then(
        (value) => {
          houseList = HouseListEntity.fromJson(json.decode(value)).data
        });
    tabController = TabController(length: state.tabList.length, vsync: this);
    pageController = PageController();
  }

  void changTab(int index) {
    pageController.animateToPage(index,
        duration: const Duration(milliseconds: 300), curve: Curves.ease);
  }

  void changPage(int index) {
    tabController.animateTo(index, duration: const Duration(milliseconds: 300));
  }
}
